//
//  NSObject+WPShowInfoHUD.m
//  wobingwoyi
//
//  Created by WGP on 16/8/1.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "NSObject+WPShowInfoHUD.h"
#import "SFHFKeychainUtils.h"

@implementation NSObject (WPShowInfoHUD)

-(void)showErrorInfoWithStatus:(NSString *)status
{
    [SVProgressHUD setMinimumDismissTimeInterval:1.5];
    [SVProgressHUD showErrorWithStatus:status];
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
    [SVProgressHUD setBackgroundColor:RGBA_COLOR(51, 51, 51, 0.8)];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
}

-(void)showSuccessInfoWithStatus:(NSString *)status
{
    [SVProgressHUD setMinimumDismissTimeInterval:1.5];
    [SVProgressHUD showSuccessWithStatus:status];
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
    [SVProgressHUD setBackgroundColor:RGBA_COLOR(51, 51, 51, 0.8)];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
}

-(void)showWithStatus:(NSString *)status
{
    [SVProgressHUD showWithStatus:status];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
    [SVProgressHUD setBackgroundColor:RGBA_COLOR(51, 51, 51, 0.8)];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
}

-(void)showProgress:(CGFloat)progress content:(NSString *)content
{
    [SVProgressHUD showProgress:progress status:content];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
    [SVProgressHUD setBackgroundColor:RGBA_COLOR(51, 51, 51, 0.8)];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
}

-(void)showInfoStatus:(NSString *)status
{
    [SVProgressHUD setMinimumDismissTimeInterval:1.5];
    [SVProgressHUD showInfoWithStatus:status];
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
    [SVProgressHUD setBackgroundColor:RGBA_COLOR(51, 51, 51, 0.8)];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
}

-(void)dismiss
{
    [SVProgressHUD dismiss];
}

-(NSString *)getsTheUniqueIdentifierForTheDevice
{
    NSString *SERVICE_NAME = [[NSBundle mainBundle] bundleIdentifier];//最好用程序的bundle id
    NSString * str =  [SFHFKeychainUtils getPasswordForUsername:@"UUID" andServiceName:SERVICE_NAME error:nil];  // 从keychain获取数据
    if ([str length]<=0)
    {
        str  = [[[UIDevice currentDevice] identifierForVendor] UUIDString];  // 保存UUID作为手机唯一标识符
        [SFHFKeychainUtils storeUsername:@"UUID"
                             andPassword:str
                          forServiceName:SERVICE_NAME
                          updateExisting:1
                                   error:nil];  // 往keychain添加数据
        str =  [SFHFKeychainUtils getPasswordForUsername:@"UUID" andServiceName:SERVICE_NAME error:nil];
        return str;
    }
    else
    {
        return str;
    }
}


@end
